package guiElements;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.net.MalformedURLException;
import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class FabricResultsPanel extends JPanel {

	private ArrayList<Fabric> fabricData;
	private JPanel loading;

	public FabricResultsPanel(ArrayList<Fabric> fabricData) {
		this.fabricData = fabricData;
		setPreferredSize(new Dimension(440, (int) (175 * Math.ceil(fabricData
				.size() / 4))));
		setLayout(new GridLayout(0, 4));
		setBackground(Color.white);
		for (int n = 0; n < fabricData.size(); n++) {
			add(fabricData.get(n));
		}
	}

	public void updateResultsPanel(ArrayList<Fabric> fabricData)
			throws MalformedURLException {
		this.removeAll();

		this.fabricData = fabricData;
		setPreferredSize(new Dimension(440, (int) (175 * Math.ceil(fabricData
				.size() / 4))));
		for (int n = 0; n < fabricData.size(); n++) {
			add(fabricData.get(n));
		}
		repaint();
		revalidate();
	}

	public ArrayList<Fabric> getFabricData() {
		return fabricData;
	}

	public void setFabricData(ArrayList<Fabric> fabricData) {
		this.fabricData = fabricData;
	}
}